﻿using GMap.NET;
using GMap.NET.MapProviders;

namespace CHDTools;

public class AMapProvider : MapProviderBase {
    public static readonly AMapProvider Instance;

    readonly Guid id = new Guid("EF3DD303-3F74-4938-BF40-232D0595EE88");

    // 高德地图的API密钥（需要你自己申请）
    private const string ApiKey = "67a9ed1dd9ca67a7f3d2f4a68a355a38";

    // 高德地图的URL模板
    private static readonly string UrlFormat =
        "http://q{0}.baidu.com/it/u=x={1};y={2};z={3};v={4};type={5}&fm={6}";

    public override Guid Id{
        get{ return id; }
    }

    readonly string name = "AMap";

    public override string Name{
        get{ return name; }
    }

    private AMapProvider(){ }

    static AMapProvider(){
        Instance = new AMapProvider();
    }

    //根据坐标和缩放，获取对应的图片。
    public override PureImage GetTileImage(GPoint pos, int zoom){
        string url = MakeTileImageUrl(pos, zoom, LanguageStr);
        return GetTileImageUsingHttp(url);
    }

    string MakeTileImageUrl(GPoint pos, int zoom, string language){
        string url = string.Format(UrlFormat, pos.X, pos.Y, zoom);
        Console.WriteLine("url:" + url);
        return url;
    }
}